package com.zy.rpc.consumer.controller;

import com.zy.rpc.api.HelloService;
import com.zy.rpc.common.dto.ApiResponse;
import com.zy.rpc.consumer.annotation.RpcAutowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author zy
 * @date 2023/5/12 15:58
 */

@RestController
@RequestMapping(value = "/helloservice")
public class HelloController {

    @RpcAutowired(version = "1.0")
    private HelloService helloService;


    @RequestMapping("/sayHello/{name}")
    public ResponseEntity<String> sayhello(@PathVariable(value = "name") String name){
        return new ResponseEntity<String>(helloService.sayHello(name), HttpStatus.OK);
    }

    @RequestMapping("/sayGoodBye/{name}")
    public ResponseEntity<String> sayGoodBye(@PathVariable(value = "name") String name){
        return new ResponseEntity<String>(helloService.sayGoodBye(name), HttpStatus.OK);
    }

    @PostMapping("/upFile")
        public ApiResponse upFile(@RequestBody MultipartFile file){

        return ApiResponse.ok();
    }
}
